package demo;

public class Test {
    public static int count = 0;
    public static void main(String[] args) throws InterruptedException {
        Thread thread1 = new Thread(()->{
            Thread t1 = Thread.currentThread();
            synchronized (t1){
                for (int i = 0; i < 5000; i++) {
                    count++;
                }
            }
        });

        Thread thread2 = new Thread(()->{
           Thread t2 = Thread.currentThread();
           synchronized (t2){
               for (int i = 0; i < 5000; i++) {
                   count++;
               }
           }
        });

        thread1.start();
        thread2.start();
        thread1.join();
        thread2.join();
        System.out.println(count);
    }
}
